#include <algorithm>
#include <cstdio>

const int N = 500005;
int n, m, a, cnt, fa[N], dep[N], son[N], siz[N], top[N], dfn[N];
int e_cnt, heads[N];

struct Edge {
  int v, nxt;
} e[N << 1];

inline void add(int u, int v) {
  e[++e_cnt].v = v, e[e_cnt].nxt = heads[u], heads[u] = e_cnt;
}

bool tag[N << 2], val[N << 2];

inline void push_down(int x) {
  if (tag[x]) {
    val[x << 1] = true, val[x << 1 | 1] = true;
    tag[x << 1] = true, tag[x << 1 | 1] = true;
    tag[x] = false;
  }
}

void modify(int x, int l, int r, int L, int R) {
  if (L <= l && r <= R) {
    tag[x] = true, val[x] = true;
    return;
  }
  int mid = (l + r) >> 1;
  push_down(x);
  if (L <= mid) modify(x << 1, l, mid, L, R);
  if (R > mid) modify(x << 1 | 1, mid + 1, r, L, R);
}

bool query(int x, int l, int r, int pos) {
  if (l == r) return val[x];
  push_down(x);
  int mid = (l + r) >> 1;
  if (pos <= mid)
    return query(x << 1, l, mid, pos);
  else
    return query(x << 1 | 1, mid + 1, r, pos);
}

inline int lca(int x, int y) {
  while (top[x] != top[y]) {
    if (dep[top[x]] < dep[top[y]]) std::swap(x, y);
    modify(1, 1, n, dfn[top[x]], dfn[x]);
    x = fa[top[x]];
  }
  if (dep[x] < dep[y]) std::swap(x, y);
  modify(1, 1, n, dfn[y], dfn[x]);
  return y;
}

void dfs1(int x) {
  siz[x] = 1;
  for (int i = heads[x], v; i; i = e[i].nxt) {
    if ((v = e[i].v) != fa[x]) {
      fa[v] = x, dep[v] = dep[x] + 1;
      dfs1(v);
      siz[x] += siz[v];
      if (siz[son[x]] < siz[v]) son[x] = v;
    }
  }
}

void dfs2(int x) {
  dfn[x] = ++cnt;
  if (son[x]) top[son[x]] = top[x], dfs2(son[x]);
  for (int i = heads[x], v; i; i = e[i].nxt) {
    if ((v = e[i].v) != fa[x] && v != son[x]) {
      top[v] = v;
      dfs2(v);
    }
  }
}

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("testdata.in", "r", stdin);
  freopen("testdata.out", "w", stdout);
#else
  freopen("train.in", "r", stdin);
  freopen("train.out", "w", stdout);
#endif
#endif

  scanf("%d%d%d", &n, &m, &a);
  int x, y;
  for (int i = 1; i < n; ++i) {
    scanf("%d%d", &x, &y);
    add(x, y), add(y, x);
  }
  fa[1] = 1, dep[1] = 1, top[1] = 1;
  dfs1(1);
  dfs2(1);
  long long ans = 0;
  x = a;
  for (int i = 1; i <= m; ++i) {
    scanf("%d", &y);
    if (!query(1, 1, n, dfn[y])) {
      ans += 0ll + dep[x] + dep[y] - (dep[lca(x, y)] << 1);
      x = y;
    }
  }
  printf("%lld", ans);
  return 0;
}